<?php
namespace app\model;

use think\Model;

class Version extends Model
{
    // 设置 JSON 字段
    protected $json = ['config'];
    // 设置JSON数据返回数组
    protected $jsonAssoc = true;

    // 软件 ID 搜索器
    public function searchSidAttr($query, $value)
    {
        !empty($value) && $query->where('sid', intval($value));
    }

    // 状态搜索器
    public function searchStatusAttr($query, $value)
    {
        !empty($value) && $query->where('status', intval($value));
    }

    //反向关联 Software
    public function software()
    {
        return $this->belongsTo(Software::class, 'sid', 'id');
    }
}